import java.util.Random;
public class PercolationStats {
    public float everyTrialsThreshold[];       //Xt array
    // perform independent trials on an n-by-n grid
    public PercolationStats(int n, int trials)
    {
        this.everyTrialsThreshold=new float[trials+1];
        Random rand = new Random();
        int a,b;

        for(int i=0;i<trials;i++)    //every trials
        {

           Percolation per=new Percolation(n);
           while(!per.percolates())    //not percolate,continue
           {

              do {
                 a=rand.nextInt(n);
                 b=rand.nextInt(n);
              } while (per.isOpen(a+1, b+1));     //这里传过去的值范围在1到n的闭区间  未打开返回0，结束循环让他打开
              
               per.open(a+1, b+1);        //open a random site
               per.numberOfOpenSites++;
           }
           this.everyTrialsThreshold[i]=per.numberOfOpenSites()/(n*n);
        }
    }

    // sample mean of percolation threshold
    public double mean()
    {
        return 1;
    }

    // sample standard deviation of percolation threshold
    public double stddev()
    {
        return 1;
    }

    // low endpoint of 95% confidence interval
    public double confidenceLo()
    {
        return 1;
    }

    // high endpoint of 95% confidence interval
    public double confidenceHi()
    {
        return 1;
    }

    public static void main(String[] args) {
        PercolationStats trials1=new PercolationStats(3,1);
    }
}
